@layout('layouts.clearly')

@section('content')
<div class="searchResults">
    <!-- Put the following javascript before the closing </head> tag. -->
    <script>
        (function() {
            var cx = '011789277816385926306:nnnb4lrcyie';
            var gcse = document.createElement('script'); gcse.type = 'text/javascript'; gcse.async = true;
            gcse.src = (document.location.protocol == 'https:' ? 'https:' : 'http:') +
                    '//www.google.com/cse/cse.js?cx=' + cx;
            var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(gcse, s);
        })();
    </script>

    <!-- Place this tag where you want the search results to render -->
    <gcse:searchresults-only></gcse:searchresults-only>
</div>
<div class="redirectBlock">
    <a href="{{ isset($redirect) ? $redirect : asset('/') }}">
        <span id="autoRedirect"></span>
        <span id="manual">Quay trở về trang chủ</span>
    </a>
</div>

@if (isset($redirect))
<!-- Redirect JavaScript -->
<script type="text/javascript">
    var timeout = <?php echo isset($timeout) ? $timeout : 3000 ?>,
            url = "<?php echo $redirect; ?>",
            $auto = $('#autoRedirect'),
            $ml = $('#manual');
    $auto.text('Tự động chuyển đến trang yêu cầu sau ' + Math.round(timeout / 1000) + ' giây');
    $ml.text('(click vào đấy nếu không tự chuyển)').css('font-size', '12px');
    setTimeout(function () {
        window.location.href = url;
    }, timeout);
</script>
@endif
@endsection